#include "InformationBox.h"
#include "Language.h"

InformationBox :: InformationBox(QWidget *parent) : QWidget(parent) {
	layout = new QGridLayout(this);
	score1 = new QLCDNumber(2, this);
	score2 = new QLCDNumber(2, this);
	logBox = new QTextBrowser(this);
	log.append("<body style=\"background-color: #F6FAFF; \">");
	logBox->setHtml(log);
	score1->display(0);
	score2->display(0);
	namePlayer1 = new QLabel("Giocatore 1", this);
	namePlayer2 = new QLabel("Giocatore 2", this);
	score1->setSegmentStyle(QLCDNumber::Flat);
	score2->setSegmentStyle(QLCDNumber::Flat);
	layout->addWidget(new QLabel(BOATNOTDESTROYEDOF, this), 0, 0, 1, 2);
	layout->addWidget(namePlayer1, 1, 0, 1, 1);
	layout->addWidget(namePlayer2, 1, 1, 1, 1);
	layout->addWidget(score1, 2, 0, 1, 1);
	layout->addWidget(score2, 2, 1, 1, 1);
	layout->addWidget(logBox, 3, 0, 1, 2);
	setLayout(layout);
}

void InformationBox :: setScorePlayer1(int num) {
	score1->display(num);
}

void InformationBox :: setScorePlayer2(int num) {
	score2->display(num);
}

void InformationBox :: setNamePlayer1(const QString& _name) {
	namePlayer1->setText(_name);
}

void InformationBox :: setNamePlayer2(const QString& _name) {
	namePlayer2->setText(_name);
}

void InformationBox :: reset() {
     log.clear();
}

void InformationBox :: setMessagePlayer1(const QString& msg) {
	log.append("<font color=\"#42AA1D\"><p size=\"11\">");
	log.append(namePlayer1->text());
	log.append(" :: ");
	log.append(msg);
	log.append("</font></p>");
	logBox->setHtml(log);
}

void InformationBox :: setMessageGame(const QString& msg) {
	log.append("<font color=\"#FFA500\"><p align=\"left\" size=\"11\">");
	log.append("Game :: ");
	log.append(msg);
	log.append("</font></p>");
	logBox->setHtml(log);
}

void InformationBox :: setMessagePlayer2(const QString& msg) {
	log.append("<font color=\"#E71521\"><p size=\"11\">");
	log.append(namePlayer2->text());
	log.append(" :: ");
	log.append(msg);
	log.append("</font></p>");
	logBox->setHtml(log);
}
